#include <gst/gst.h>

static void cb_new_pad (GstElement *element, GstPad *pad, gpointer data)
{
    gchar *name = NULL;
    element = element;
    data = data;
    name = gst_pad_get_name (pad);
    g_print ("A new pad %s was created\n", name);
    g_free (name);
}

int main(int argc, char *argv[])
{
    GstElement *pipeline = NULL;
    GstElement *source = NULL;
    GstElement *demux = NULL;
    GMainLoop *loop = NULL;

    /* init */
    gst_init(&argc, &argv);

    /* create elements */
    pipeline = gst_pipeline_new("My-pipeline");
    source = gst_element_factory_make("filesrc", "source");
    demux = gst_element_factory_make ("oggdemux", "demuxer");
    if (!pipeline
            || !source
            || !demux) {
        g_warning("Create element failed");
        return -1;
    }

    /* put together a pipeline */
    gst_bin_add_many(GST_BIN(pipeline), source, demux, NULL);
    gst_element_link_pads(source, "src", demux, "sink");

    /* listen for newly created pads */
    g_signal_connect(demux, "pad-added", G_CALLBACK(cb_new_pad), NULL);

    /* start the pipeline */
    gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING);
    loop = g_main_loop_new(NULL, FALSE);

    g_main_loop_run(loop);

    return 0;
}
